A Solid State Disk (SSD) is formed by an array of solid state electronic storage chips. In the case where NAND flashes are adopted as storage media in the SSD, before data is written to a physical block of the SSD, the original data in the physical block needs to be erased. Considering the limited allowable erase count of the physical block, the physical block will become invalid if the limited allowable erase count of the physical block is reached, and data loss occurs if the data is written to the invalid physical block. Therefore, to ensure data security, wear leveling of physical blocks in the SSD is performed to make the erase counts of the physical blocks as even as possible, and to avoid the loss of data written to a certain physical block which has been erased for excessive times.
It is assumed that the allowable erase count of each physical block in the SSD is the same as that in any other physical block in the SSD in the prior art, thus the erase count of each physical block of the SSD may be made even with that in the other physical blocks of the SSD by writing data to a physical block which has been erased for a relatively small number of times. However, due to factors such as the limitation of SSD manufacturing technique and mixed use of old and new SSDs, not all of the physical blocks share the same allowable erase count, instead, a certain physical block which has been erased for a relatively small number of times and selected for storing data might have a relatively small allowable erase count, that is, the residual service life of the selected physical block may be shorter than that of a physical block which has been erased for more times, thus a data loss occurs when data is written to the selected physical block, thereby degrading data security.
For example, in the case where the allowable erase count of a free first physical block is 2000 and the allowable erase count of a free second physical block is 10000, if the first physical block has been erased for 1950 times and the second physical block has been erased for 2000 times, then data will be written to the first physical block that has been erased for less times instead of the second physical block which is provided with a larger allowable erase count, as a result, the current erase count of the first physical block is close to the allowable erase count of the first physical block, thereby degrading the security of data written to the first physical block.
The disclosed method and system are directed to solve one or more problems set forth above and other problems.